﻿
@{
    ViewBag.Title = "InfoView";
    Layout = "~/Views/Shared/_MyLayout.cshtml";
}

<div style="margin-top:10px;">
    <form class="layui-form" id="FormInfo" >
        <div class="layui-form-item">
            <label class="layui-form-label">项目编号</label>
            <div class="layui-input-inline">
                <input type="text" name="ProJectCode" value="@ViewBag.ProJectCode" required lay-verify="required" placeholder="请输入编号" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">项目名称</label>
            <div class="layui-input-inline">
                <input type="text" name="Name" value="@ViewBag.Name" required lay-verify="required" placeholder="请输入项目名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">工作内容</label>
            <div class="layui-input-block" style="width:800px;">
                <textarea name="Content"  placeholder="请输入工作内容" class="layui-textarea">@ViewBag.Content</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">地址</label>
            <div class="layui-input-block">
                <input type="text" name="Adress" value="@ViewBag.Adress" required lay-verify="required" placeholder="请输入地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">合同<br>签订时间</label>
            <div class="layui-input-inline">
                <input type="text" name="ContrTime" value="@ViewBag.ContrTime" id="BidTime" required lay-verify="required" placeholder="请输选择时间" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">项目类型</label>
            <div class="layui-input-inline">
                <input type="text" name="type" value="@ViewBag.type" required lay-verify="required" placeholder="主业|多经|用户工程等" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">合同金额</label>
            <div class="layui-input-inline">
                <input type="number" name="ConAmount" value="@ViewBag.ConAmount" placeholder="合同金额" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">

        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">付款方式</label>
            <div class="layui-input-block" style="width:800px;">
                <textarea name="PayStyle" placeholder="输入付款方式" class="layui-textarea">@ViewBag.PayStyle</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" id="mysubmit" class="layui-btn" lay-submit lay-filter="formVerify" style="display:none;">立即提交</button>
                <button type="button" class="layui-btn" id="BtnSave">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>

<script>
    var ProjectId = "@ViewBag.ProjectId";
    var state = "@ViewBag.state";
    layui.use([ 'form', 'laydate'], function(){
        var form = layui.form;
        var laydate = layui.laydate;
        var IsValidate = 0;        

        //拦截form提交消息
        form.on('submit(formVerify)', function (data) {
            //layer.msg(JSON.stringify(data.field));
            IsValidate = 1;
            return false;
        });

        laydate.render({
            elem: '#BidTime' //指定元素
        });
        
        $("#BtnSave").on("click", function () {

            $("#mysubmit").click();
            if (IsValidate == 1) {
                IsValidate = 0;
                var obj = $("#FormInfo").serializeArray();
                var data = {};
                $.each(obj, function (i, v) {
                    data[v.name] = v.value;
                });              
                data["ProjectId"] = ProjectId;
                $.ajax({
                    type: "POST",
                    url: "/Project/InfoUpdata",
                    async: false,
                    contentType: "application/json",
                    dataType: "json",
                    data: JSON.stringify(data),
                    success: function (msg) {
                        if (msg.result == "OK") {
                            parent.layer.msg('修改成功', { icon: 6, time: 1000 });
                            //parent.table.reload("demo");
                            //var index = parent.layer.getFrameIndex(window.name);
                            //parent.layer.close(index);

                            parent.layui.admin.events.closeThisTabs();
                        } else {
                            alert(msg.result);
                        }
                    }
                });

            }
        });









    });
</script>


